package main

import "fmt"

func main() {
	var inputString string
	result := 1
	havekuohao := false

	n, _ := fmt.Scan(&inputString)
	if n == 0 {
		result = 0
	}

	var stack []rune

	for _, inputRune := range []rune(inputString) {

		switch inputRune {
		case '(':
			stack = append(stack, inputRune)
			havekuohao = true
		case '[':
			stack = append(stack, inputRune)
			havekuohao = true
		case '{':
			stack = append(stack, inputRune)
			havekuohao = true
		case '<':
			stack = append(stack, inputRune)
			havekuohao = true
		case ')':
			if len(stack) == 0 {
				result = 0
			} else if stack[len(stack)-1] == '(' {
				stack = stack[:len(stack)-1]
			} else {
				result = 0
			}
			havekuohao = true
		case ']':
			if len(stack) == 0 {
				result = 0
			} else if stack[len(stack)-1] == '[' {
				stack = stack[:len(stack)-1]
			} else {
				result = 0
			}
			havekuohao = true
		case '}':
			if len(stack) == 0 {
				result = 0
			} else if stack[len(stack)-1] == '{' {
				stack = stack[:len(stack)-1]
			} else {
				result = 0
			}
			havekuohao = true
		case '>':
			if len(stack) == 0 {
				result = 0
			} else if stack[len(stack)-1] == '<' {
				stack = stack[:len(stack)-1]
			} else {
				result = 0
			}
			havekuohao = true
		default:
			continue
		}
	}

	if havekuohao {
		fmt.Println(result)
	} else {
		fmt.Println(1)
	}

}
